package com.yanqu.road.dataHelper.action.userCenterScript;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dataHelper.manager.BaseMgr;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class OrderScript extends BaseMgr {

    public OrderScript(){

    }

    public List<Map<String,String>> getOrder(String start, String end) {
        List<Map<String ,String>> dataList = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "SELECT * FROM t_s_recharge_detail WHERE `time` > ? AND `time` < ?";
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            call.setString(1, start);
            call.setString(2, end);
            rs = call.executeQuery();
            while (rs.next()) {
                Map<String,String> temp = new ConcurrentHashMap<>();
                temp.put("serverId",rs.getString("serverId"));
                temp.put("userId",rs.getString("userId"));
                temp.put("mallId",rs.getString("mallId"));
                temp.put("price",rs.getString("price"));
                temp.put("type",rs.getString("type"));
                temp.put("time",rs.getString("time"));
                dataList.add(temp);
            }
        } catch (SQLException ex) {
            logger.error("异常错误", ex);
        } finally {
            getDb().closeConnection(call, null);
        }
        return dataList;
    }
}
